// single comment on hashmapto arraylist

//kkkk
//snd time
package com.collections;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class HashMapToArrayList {

	
	public static void main(String[] args) {
		
		//HashMap
		//iuhuihiuhi
		HashMap<Integer, String> hm=new HashMap<Integer, String>();
		hm.put(418,"Mallikharjun");
		hm.put(419,"Manikantha");
		hm.put(420,"Manohar");
		hm.put(420, "MadRao");////madrao replace Manohar why b/z HM not allow duplicate values
		hm.put(null,"Kavya");
		hm.put(null,"Kavya");
		
		
		System.out.println("hashmap...."+hm);
		
		//Methods..in...hashmap..............
		// Get a set of the entries
	    Set set = hm.entrySet();
	    System.out.println(set);
	      
	    HashMap hmclone=(HashMap)hm.clone();
	    System.out.println("Clone Method"+ hmclone); 
	    
	    System.out.println("containskey method=="+hm.containsKey(418));
	    System.out.println("containskey method=="+hm.containsKey(420));
	    
	    System.out.println("contains value method=="+hm.containsValue("Kavya"));
	    System.out.println("contains value method=="+hm.containsValue("Ka"));

	    hm.putAll(hm);
	    System.out.println(hm);
	    
	    System.out.println("hash code for hm...."+hm.hashCode());
	    System.out.println("hash code for hmclone...."+hmclone.hashCode());
	    
	    Set set1=hm.entrySet();
	    System.out.println("entry set result"+set1);
	      
	    System.out.println("values"+hm.values());
	    
	    System.out.println("size()''''"+hm.size());
	    
	    hm.remove(null);
	    System.out.println("after remove one of duplicate..."+hm);
	    
	    System.out.println("key set method..."+hm.keySet());
	    
	    hm.clear();
	    System.out.println("after clear..."+hm);
	    
	    System.out.println("isEmpty after clear.."+hm.isEmpty());
	    
	    System.out.println("hash code for hm...."+hm.hashCode());
	    System.out.println("hash code for hm1..."+hmclone.hashCode());
	    Set setclone=hmclone.entrySet();
	    ArrayList al=new ArrayList();
	    Iterator it=setclone.iterator();
	    while(it.hasNext())
	    {
	    	al.add(it.next());
	    }
	    System.out.println("array list..."+al);
	    
	    Set keys=hmclone.keySet();
	    Iterator itkeys=keys.iterator();
	    while(itkeys.hasNext())
	    {
	    	al.add(itkeys.next());
	    }
	    System.out.println("array list with keys..."+al);
	    System.out.println(al.get(5));
	    
	    Iterator itdup=setclone.iterator();
	    while(itdup.hasNext())
	    {
	    	al.add(itdup.next());
	    }
	    System.out.println("array list..."+al);

	}

}
